\(\int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx\) [620]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F(-1)]
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 30, antiderivative size = 54 \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=-x+\frac {4 a \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b} d} \]

[Out]

-x+4*a*arctan((a-b)^(1/2)*tan(1/2*d*x+1/2*c)/(a+b)^(1/2))/d/(a-b)^(1/2)/(a+b)^(1/2)

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {3095, 2814, 2738, 211} \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=\frac {4 a \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{d \sqrt {a-b} \sqrt {a+b}}-x \]

[In]

Int[(a^2 - b^2*Cos[c + d*x]^2)/(a + b*Cos[c + d*x])^2,x]

[Out]

-x + (4*a*ArcTan[(Sqrt[a - b]*Tan[(c + d*x)/2])/Sqrt[a + b]])/(Sqrt[a - b]*Sqrt[a + b]*d)

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 2738

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[2*(e/d), Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rule 2814

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*(x/d)
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 3095

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (C_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
C/b^2, Int[(a + b*Sin[e + f*x])^(m + 1)*Simp[-a + b*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, e, f, A, C, m}, x
] && EqQ[A*b^2 + a^2*C, 0]

Rubi steps \begin{align*} \text {integral}& = -\int \frac {-a+b \cos (c+d x)}{a+b \cos (c+d x)} \, dx \\ & = -x+(2 a) \int \frac {1}{a+b \cos (c+d x)} \, dx \\ & = -x+\frac {(4 a) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{d} \\ & = -x+\frac {4 a \arctan \left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} \sqrt {a+b} d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.16 (sec) , antiderivative size = 53, normalized size of antiderivative = 0.98 \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=-x-\frac {4 a \text {arctanh}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2} d} \]

[In]

Integrate[(a^2 - b^2*Cos[c + d*x]^2)/(a + b*Cos[c + d*x])^2,x]

[Out]

-x - (4*a*ArcTanh[((a - b)*Tan[(c + d*x)/2])/Sqrt[-a^2 + b^2]])/(Sqrt[-a^2 + b^2]*d)

Maple [A] (verified)

Time = 1.45 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.09

method result size
derivativedivides \(\frac {-2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\frac {4 a \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}}{d}\) \(59\)
default \(\frac {-2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\frac {4 a \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}}{d}\) \(59\)
risch \(-x -\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, d}+\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {-i a^{2}+i b^{2}+a \sqrt {-a^{2}+b^{2}}}{\sqrt {-a^{2}+b^{2}}\, b}\right )}{\sqrt {-a^{2}+b^{2}}\, d}\) \(143\)

[In]

int((-b^2*cos(d*x+c)^2+a^2)/(a+cos(d*x+c)*b)^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(-2*arctan(tan(1/2*d*x+1/2*c))+4*a/((a-b)*(a+b))^(1/2)*arctan((a-b)*tan(1/2*d*x+1/2*c)/((a-b)*(a+b))^(1/2)
))

Fricas [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 218, normalized size of antiderivative = 4.04 \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=\left [-\frac {{\left (a^{2} - b^{2}\right )} d x + \sqrt {-a^{2} + b^{2}} a \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right )}{{\left (a^{2} - b^{2}\right )} d}, -\frac {{\left (a^{2} - b^{2}\right )} d x - 2 \, \sqrt {a^{2} - b^{2}} a \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right )}{{\left (a^{2} - b^{2}\right )} d}\right ] \]

[In]

integrate((a^2-b^2*cos(d*x+c)^2)/(a+b*cos(d*x+c))^2,x, algorithm="fricas")

[Out]

[-((a^2 - b^2)*d*x + sqrt(-a^2 + b^2)*a*log((2*a*b*cos(d*x + c) + (2*a^2 - b^2)*cos(d*x + c)^2 + 2*sqrt(-a^2 +
 b^2)*(a*cos(d*x + c) + b)*sin(d*x + c) - a^2 + 2*b^2)/(b^2*cos(d*x + c)^2 + 2*a*b*cos(d*x + c) + a^2)))/((a^2
 - b^2)*d), -((a^2 - b^2)*d*x - 2*sqrt(a^2 - b^2)*a*arctan(-(a*cos(d*x + c) + b)/(sqrt(a^2 - b^2)*sin(d*x + c)
)))/((a^2 - b^2)*d)]

Sympy [F(-1)]

Timed out. \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=\text {Timed out} \]

[In]

integrate((a**2-b**2*cos(d*x+c)**2)/(a+b*cos(d*x+c))**2,x)

[Out]

Timed out

Maxima [F(-2)]

Exception generated. \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate((a^2-b^2*cos(d*x+c)^2)/(a+b*cos(d*x+c))^2,x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more de

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 254 vs. \(2 (45) = 90\).

Time = 0.33 (sec) , antiderivative size = 254, normalized size of antiderivative = 4.70 \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=\frac {\frac {{\left (\sqrt {a^{2} - b^{2}} {\left (a + b\right )} {\left | a - b \right |} {\left | b \right |} + \sqrt {a^{2} - b^{2}} {\left (3 \, a b - b^{2}\right )} {\left | a - b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a + \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )}}{{\left (a^{2} - 2 \, a b + b^{2}\right )} b^{2} + {\left (a^{3} - 2 \, a^{2} b + a b^{2}\right )} {\left | b \right |}} + \frac {{\left (3 \, a b - b^{2} - a {\left | b \right |} - b {\left | b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a - \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )}}{b^{2} - a {\left | b \right |}}}{d} \]

[In]

integrate((a^2-b^2*cos(d*x+c)^2)/(a+b*cos(d*x+c))^2,x, algorithm="giac")

[Out]

((sqrt(a^2 - b^2)*(a + b)*abs(a - b)*abs(b) + sqrt(a^2 - b^2)*(3*a*b - b^2)*abs(a - b))*(pi*floor(1/2*(d*x + c
)/pi + 1/2) + arctan(2*sqrt(1/2)*tan(1/2*d*x + 1/2*c)/sqrt((2*a + sqrt(-4*(a + b)*(a - b) + 4*a^2))/(a - b))))
/((a^2 - 2*a*b + b^2)*b^2 + (a^3 - 2*a^2*b + a*b^2)*abs(b)) + (3*a*b - b^2 - a*abs(b) - b*abs(b))*(pi*floor(1/
2*(d*x + c)/pi + 1/2) + arctan(2*sqrt(1/2)*tan(1/2*d*x + 1/2*c)/sqrt((2*a - sqrt(-4*(a + b)*(a - b) + 4*a^2))/
(a - b))))/(b^2 - a*abs(b)))/d

Mupad [B] (verification not implemented)

Time = 1.84 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.28 \[ \int \frac {a^2-b^2 \cos ^2(c+d x)}{(a+b \cos (c+d x))^2} \, dx=-x-\frac {4\,a\,\mathrm {atanh}\left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}\right )}{d\,\sqrt {b^2-a^2}} \]

[In]

int((a^2 - b^2*cos(c + d*x)^2)/(a + b*cos(c + d*x))^2,x)

[Out]

- x - (4*a*atanh((a*sin(c/2 + (d*x)/2) - b*sin(c/2 + (d*x)/2))/(cos(c/2 + (d*x)/2)*(b^2 - a^2)^(1/2))))/(d*(b^
2 - a^2)^(1/2))